//
//  EmoticonAttachment.swift
//  01表情键盘
//
//  Created by 龚欣 on 15/7/8.
//  Copyright © 2015年 gong. All rights reserved.
//

import UIKit

class EmoticonAttachment: NSTextAttachment {
    
    var chs : String?
    
    class func emoticonString(emoticon : Emoticon, font : UIFont) -> NSAttributedString{
        let attachment = EmoticonAttachment()
        
        
        attachment.chs = emoticon.chs
        attachment.image = UIImage(contentsOfFile: emoticon.imagePath!)
        
        let s = font.lineHeight
        attachment.bounds = CGRect(x: 0, y: -2, width: s, height: s)
        
        let imageText = NSAttributedString(attachment: attachment)
        
        let strM = NSMutableAttributedString(attributedString: imageText)
        strM.addAttributes([NSFontAttributeName : font], range: NSMakeRange(0, 1))
        return strM
    }
}
